package com.xci.xajtfb.bus.api;

import com.github.lvyanyang.annotation.Authorize;
import com.github.lvyanyang.core.*;
import com.github.lvyanyang.model.IdBody;
import com.github.lvyanyang.model.IdsStatusBody;
import com.xci.xajtfb.bus.entity.WxEvaluation;
import com.xci.xajtfb.bus.filter.WxEvaluationFilter;
import com.xci.xajtfb.bus.service.WxEvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 出租评价接口
 * @author 焦元义
 * @since 2021-03-02 13:50:24
 */
@Api(tags = "出租评价接口")
@Authorize
@RestController
@RequestMapping(value = "/api/bus/wxevaluation", produces = Const.PROJSON)
public class WxEvaluationApiController extends BaseController {
    /** 出租评价服务 */
    @Resource
    private WxEvaluationService wxevaluationService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新建出租评价")
    //@Authorize(code = "bus.wxevaluation.insert")
    @PostMapping("/insert")
    public BoolResult insert(@RequestBody WxEvaluation entity) {
        return wxevaluationService.insert(entity);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "修改出租评价")
    //@Authorize(code = "bus.wxevaluation.update")
    @PostMapping("/update")
    public BoolResult update(@RequestBody WxEvaluation entity) {
        return wxevaluationService.update(entity);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "修改出租评价状态")
    //@Authorize(code = "bus.wxevaluation.updateStatus")
    @PostMapping(value = "/updateStatus")
    public BoolResult updateStatus(@RequestBody IdsStatusBody body) {
        wxevaluationService.updateStatus(body.getIds(), body.getStatus());
        return BoolResult.success();
    }

    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "根据主键查询单个出租评价")
    //@Authorize(code = "bus.wxevaluation.select")
    @PostMapping("/selectById")
    public BoolResult<WxEvaluation> selectById(@RequestBody IdBody body) {
        return BoolResult.success(wxevaluationService.selectById(body.getId()));
    }

    //@ApiOperationSupport(order = 8)
    //@ApiOperation(value = "根据编码查询单个出租评价")
    ////@Authorize(code = "bus.wxevaluation.select")
    //@PostMapping("/selectByCode")
    //public BoolResult<Wxevaluation> selectByCode(@RequestBody CodeBody body) {
    //    return BoolResult.success(wxevaluationService.selectByCode(body.getCode()));
    //}

    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "查询出租评价分页列表")
    //@Authorize(code = "bus.wxevaluation.select")
    @PostMapping("/selectPageList")
    public BoolResult<PageList<WxEvaluation>> selectPageList(@RequestBody WxEvaluationFilter filter) {
        return BoolResult.success(wxevaluationService.selectPageList(filter));
    }

    @ApiOperationSupport(order = 10, ignoreParameters = {Const.IPI, Const.IPS, Const.IPSN, Const.IPSD})
    @ApiOperation(value = "查询出租评价列表")
    //@Authorize(code = "bus.wxevaluation.select")
    @PostMapping("/selectList")
    public BoolResult<List<WxEvaluation>> selectList(@RequestBody WxEvaluationFilter filter) {
        return BoolResult.success(wxevaluationService.selectList(filter));
    }

    @ApiOperationSupport(order = 11, ignoreParameters = {Const.IPI, Const.IPS, Const.IPSN, Const.IPSD})
    @ApiOperation(value = "导出出租评价列表")
    //@Authorize(code = "bus.wxevaluation.export")
    @PostMapping(value = "/export", produces = {Const.PROOCTET, Const.PROJSON})
    public void export(@RequestBody WxEvaluationFilter filter) {
        XCI.exportExcel(wxevaluationService.selectList(filter), WxEvaluation.class, "出租评价列表");
    }

    //@ApiOperationSupport(order = 12)
    //@ApiOperation(value = "获取出租评价导出字段")
    //@PostMapping(value = "/exportNames")
    //public BoolResult<List<String>> exportNames() {
    //    return BoolResult.success(XCI.getExcelFiledNames(Wxevaluation.class));
    //}
}
